﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using AgencyManagerSystem.Common;
using AgencyManagerSystem.DataUpdater;


namespace AgencyManagerSystem.Core
{
    public abstract class MainDetailUpdaterCreator<TMain,TDetail>:BaseUpdaterCreator<TMain> where TMain : DBModel where TDetail : DBModel
    {
        protected virtual void CommonValid(MainDetailUpdater<TMain,TDetail> sender, DataBulkUpdatingEventArgs<TMain,TDetail> e)
        {
            var cntWithZeroAutoId = from item in e.DetailInsert where item.AutoId > 0 select item;
            if (e.Insert.AutoId==0&&cntWithZeroAutoId.Count()>0)
            {
                e.Cancel = true;
                e.Message = "明细记录的autoid状态必须为[新建]";
            }
        }
    }
}
